package cn.tedu;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class Demo06 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入用户名.....");
        String username=sc.nextLine();
        System.out.println("请把密码输入进来...");
        String password=sc.nextLine();
        /*
        在终端执行下面SQL语句
        create table user(id int primary key auto_increment,
        username varchar(50),password varchar(50));
         */
        try( Connection conn=DBUtils.getConn()) {
            String sql="insert into user values(null" +
                    ",'"+username+"','"+password+"')";
            //创建执行SQL语句对象
            Statement s=conn.createStatement();
            //执行SQL语句
            s.executeUpdate(sql);
            System.out.println("注册成功!");
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
